Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat incentive offers #258

Closed
wants to merge 4 commits into from

Conversation

dev129
Copy link

@dev129 dev129 commented Oct 12, 2024

PR Title: Add Offer Modal with Highlighted CTA Button (#196)

Description:

This PR addresses issue #196 by implementing an exciting offer modal to encourage users to explore the menu and discover more about the café. The modal introduces a clear and engaging call-to-action (CTA) with the following key features:

  • Exciting Offer Design: The modal features an eye-catching offer image alongside a bold title, making the offer more appealing to users.
  • Clear Call-to-Action: The “Take Me There” button is highlighted in a dark beige shade, designed to make the user more inclined to explore the menu and check out the offers.
  • Smooth Modal Behavior:
    • No Thanks Button: Closes the modal without navigating.
    • Take Me There Button: Closes the modal and seamlessly redirects the user to the /menu page.
  • User Experience Improvement: This design helps capture the user’s attention by providing an interactive way to explore ongoing promotions and learn more about the café’s offerings.

Changes Included:

  • Added offer modal component with dynamic closing and navigation behavior.
  • Enhanced user flow by preventing background scrolling when the modal is open.
  • Applied user-friendly styling to ensure buttons are noticeable, with hover transitions for a better experience.

Impact:
This feature not only drives users to check the menu but also encourages them to engage further with the website, potentially increasing traffic and conversions for promotional offers.

Please review the changes and provide feedback if necessary!

Closes #196 .

Summary by CodeRabbit

  • New Features
    • Introduced a new modal component for displaying promotional offers.
    • Enhanced navigation with updated styling and improved logout functionality.
  • Updates
    • Updated contributors' section in the README with new entries and links.
    • Added state management for modal visibility in the main app component.
  • Styling
    • Adjusted class names for the navigation bar to meet new design requirements.

Copy link

vercel bot commented Oct 12, 2024

@github-actions[bot] is attempting to deploy a commit to the bunty's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Oct 12, 2024

Caution

Review failed

The head commit changed during the review from ead4632 to 8184d36.

Walkthrough

The changes in this pull request involve updates to the README.md file, modifications to the App component, and the introduction of a new Offers component in the frontend application. The README.md was updated to reflect changes in contributor information. The App component now manages a modal's visibility through state, while the Navbar component underwent styling and logout functionality enhancements. The new Offers component serves as a modal for displaying promotional offers, contributing to the goal of improving customer retention and driving traffic to the website.

Changes

File Change Summary
README.md Updated contributors' section with new entries and links; several contributors were removed or modified.
frontend/src/App.jsx Added state management for modal visibility and integrated Offers component with props for visibility and close functionality.
frontend/src/components/Shared/Navbar.jsx Updated class names for styling, modified logout functionality, and adjusted the logout confirmation button text.
frontend/src/components/Shared/Offers.jsx Introduced a new Offers component to display promotional offers with modal functionality and navigation.

Assessment against linked issues

Objective Addressed Explanation
Improve customer retention and drive traffic by offering incentives like discounts and deals. (#196)
Provide customers with regular discounts and special offers. (#196)
Add an email subscription option for exclusive offers. (#196) No implementation for email subscription was included.
Include a link for senior citizens to a WhatsApp community for offers. (#196) No implementation for WhatsApp community link was included.

Possibly related PRs

Suggested labels

enhancement, level 2, gssoc-ext, hacktoberfest-accepted

Suggested reviewers

  • RamakrushnaBiswal

Poem

In the garden of code, we hop and play,
New faces join, brightening the way.
Offers abound, like carrots so sweet,
With every click, our users we greet.
So here's to the changes, both big and small,
Together we flourish, together we stand tall! 🐰✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

Thank you for submitting your pull request! 🙌 We'll review it as soon as possible. In the meantime, please ensure that your changes align with our CONTRIBUTING.md. If there are any specific instructions or feedback regarding your PR, we'll provide them here. Thanks again for your contribution! 😊

Copy link

vercel bot commented Oct 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
play-cafe ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 13, 2024 2:30am

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (4)
frontend/src/App.jsx (2)

12-12: Consider user experience for returning visitors.

The showModal state is correctly implemented. However, setting it to true by default means the offer will show every time the app loads, which might be intrusive for returning users.

Consider using local storage or cookies to track if the user has seen the offer recently, and only show it to new visitors or after a certain time has passed.

Example implementation:

const [showModal, setShowModal] = useState(() => {
  const lastShown = localStorage.getItem('lastOfferShown');
  const showAgain = !lastShown || (Date.now() - parseInt(lastShown)) > (24 * 60 * 60 * 1000); // 24 hours
  if (showAgain) {
    localStorage.setItem('lastOfferShown', Date.now().toString());
  }
  return showAgain;
});

16-16: LGTM: Offers component is correctly implemented.

The Offers component is properly integrated into the App structure with correct props for visibility control and closing functionality. This aligns well with the PR objective of introducing an offer modal to enhance user engagement.

Consider memoizing the onClose function to optimize performance, especially if the App component re-renders frequently:

const onCloseModal = React.useCallback(() => setShowModal(false), []);

// Then in the JSX:
<Offers isVisible={showModal} onClose={onCloseModal} />
frontend/src/components/Shared/Offers.jsx (1)

28-83: LGTM: Modal structure and styling are well-implemented. Consider improving accessibility.

The modal structure is well-organized, and the use of Tailwind CSS classes provides consistent styling. The two-column layout with an image and text content is visually appealing. Good job on implementing hover effects for buttons to enhance user interaction.

To improve accessibility, consider the following enhancements:

  1. Add aria-label to the close button:
 <button
   className="absolute top-2 right-2 text-black text-xl"
   onClick={() => onClose()}
+  aria-label="Close offer modal"
 >
   <RxCross1 color='black' />
 </button>
  1. Add role="dialog" and aria-modal="true" to the main modal div:
-<div className='fixed inset-0 bg-white bg-opacity-25 backdrop-blur-lg flex justify-center items-center z-30'>
+<div className='fixed inset-0 bg-white bg-opacity-25 backdrop-blur-lg flex justify-center items-center z-30' role="dialog" aria-modal="true">
  1. Consider trapping focus within the modal when it's open to improve keyboard navigation.

These changes will make the modal more accessible to users relying on screen readers or keyboard navigation.

frontend/src/components/Shared/Navbar.jsx (1)

Line range hint 46-53: Approve logout functionality changes with a minor suggestion.

The updates to the handleLogout function are well-implemented. They align with a token-based authentication system and provide a more comprehensive logout process. This contributes to a better user experience, which aligns with the PR objectives.

Consider adding a success message or toast notification to inform the user that they have been successfully logged out. This could further enhance the user experience.

Example implementation:

const handleLogout = () => {
  Cookies.remove("authToken");
  setToken(null);
  setIsModalOpen(false);
  setIsMenuOpen(false);
  // Add a success message here
  // toast.success("You have been successfully logged out");
  navigate("/login");
};
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 253c0f3 and e2ad349.

📒 Files selected for processing (4)
  • README.md (6 hunks)
  • frontend/src/App.jsx (2 hunks)
  • frontend/src/components/Shared/Navbar.jsx (1 hunks)
  • frontend/src/components/Shared/Offers.jsx (1 hunks)
🧰 Additional context used
🪛 Markdownlint
README.md

164-164: Column: 1
Hard tabs

(MD010, no-hard-tabs)


165-165: Column: 1
Hard tabs

(MD010, no-hard-tabs)


208-208: Column: 1
Hard tabs

(MD010, no-hard-tabs)


209-209: Column: 1
Hard tabs

(MD010, no-hard-tabs)


252-252: Column: 1
Hard tabs

(MD010, no-hard-tabs)


253-253: Column: 1
Hard tabs

(MD010, no-hard-tabs)


296-296: Column: 1
Hard tabs

(MD010, no-hard-tabs)


297-297: Column: 1
Hard tabs

(MD010, no-hard-tabs)

🔇 Additional comments (13)
frontend/src/App.jsx (3)

3-4: LGTM: New imports are correctly added.

The new imports for React, useState, and the Offers component are correctly placed and necessary for the implemented changes.

Also applies to: 10-10


25-25: LGTM: Export statement moved for better readability.

Moving the export statement to a separate line is a good practice that improves code clarity without affecting functionality.


Line range hint 1-25: Summary: Implementation aligns well with PR objectives.

The changes in this file successfully introduce the offer modal, aligning with the PR objective of enhancing user engagement through incentives and special offers. The modal's visibility is controlled by state, allowing for dynamic display.

To further improve on the objectives:

  1. Consider implementing a mechanism to show offers less frequently to returning users, as suggested earlier.
  2. Think about how this modal could be used to display different types of offers (e.g., "Product of the Day", "Deal of the Day") to align with the objective of implementing regular discounts and promotions.
  3. Consider adding a way for users to subscribe to offers directly from this modal, addressing the email subscription objective.

Overall, this is a solid foundation for the new feature. Great work!

frontend/src/components/Shared/Offers.jsx (4)

1-6: LGTM: Imports and component declaration are well-structured.

The imports are appropriate for the component's functionality, and the component declaration follows React best practices. Good job on using named imports and declaring the component with clear prop names.


20-26: LGTM: Conditional rendering and navigation handling are well-implemented.

The conditional rendering to return null when !isVisible is a good practice for performance. The handleTakeMeThere function correctly closes the modal before navigation, which helps prevent potential issues with modal state.


87-87: LGTM: Component export is correct.

The default export of the Offers component follows common React practices and allows for easy import in other parts of the application.


1-87: Overall assessment: Well-implemented component meeting PR objectives.

The Offers component successfully implements the requirements outlined in the PR objectives. It provides an appealing modal for displaying promotional offers, which can help improve customer retention and drive traffic to the website. The component is well-structured, uses React hooks effectively, and follows good coding practices.

Key strengths:

  1. Responsive design with a visually appealing two-column layout.
  2. Proper management of modal visibility and body scroll locking.
  3. Clear call-to-action buttons with hover effects.
  4. Integration with react-router for seamless navigation.

Areas for improvement:

  1. Enhance accessibility as suggested in previous comments.
  2. Consider using CSS classes for managing body overflow instead of direct DOM manipulation.

Overall, this component is a valuable addition to the application and aligns well with the goals of improving customer engagement and retention.

frontend/src/components/Shared/Navbar.jsx (3)

Line range hint 1-238: Summary of Navbar component changes

Overall, the changes to the Navbar component align well with the PR objectives and contribute to improving the user experience. Key improvements include:

  1. Enhanced logout functionality with proper token management.
  2. Improved text formatting for consistency.
  3. Potential adjustment to the navbar's z-index for better layout management.

These changes support the goal of improving customer retention by providing a more polished and user-friendly interface. The logout process is now more secure and comprehensive, which indirectly contributes to better user engagement.

To further align with the PR objectives, consider the following suggestions:

  1. Implement the success message for logout as suggested earlier.
  2. Ensure consistent casing across all buttons in the application.
  3. Verify the z-index change doesn't negatively impact the navbar's visibility or functionality.

These enhancements will further contribute to a seamless user experience, potentially increasing user engagement with the café's menu and special offers.


Line range hint 201-201: Approve text change and suggest consistency.

The change from "LOGOUT" to "Log Out" in the mobile menu improves the text formatting and aligns with common UI practices. This enhancement contributes to a better user experience, which is in line with the PR objectives.

For consistency, consider applying the same casing style to other buttons in the application, such as the "LOGIN" button. This will ensure a uniform look across the UI.

Let's check for other instances of "LOGIN" or "LOGOUT" in the codebase:

#!/bin/bash
# Search for LOGIN or LOGOUT in all files
rg -i '\b(login|logout)\b' -n

This will help us identify any other occurrences that might need to be updated for consistency.


73-76: Verify the intention behind changing the z-index.

The z-index of the navbar has been reduced from 50 to 20. This change might affect the visibility of the navbar in relation to other elements on the page.

Could you please clarify the reasoning behind this change? Are there any specific UI elements that should now appear above the navbar?

To help assess the impact, let's check for other z-index values in the codebase:

This will help us understand if there are any potential conflicts with other elements' z-index values.

README.md (3)

151-154: LGTM: Contributors section updated appropriately.

The changes to the contributors section have been implemented correctly. The updates maintain the existing structure and formatting of the contributors table while adding new contributors and updating existing entries.

Also applies to: 164-165, 181-184, 194-200, 208-209, 232-235, 239-242, 252-253


164-165: Note: Linter warnings about hard tabs can be ignored.

The static analysis tool (Markdownlint) has flagged the use of hard tabs in the HTML tags of the contributors table. However, these warnings can be safely ignored for the following reasons:

  1. The hard tabs are used in HTML tags within a Markdown file, which doesn't affect the rendered output.
  2. Changing the indentation of these HTML tags is unlikely to improve readability or functionality.
  3. Modifying these lines might interfere with any automated processes that manage the contributors table.

No action is required for these linter warnings.

Also applies to: 208-209, 252-253, 296-297

🧰 Tools
🪛 Markdownlint

164-164: Column: 1
Hard tabs

(MD010, no-hard-tabs)


165-165: Column: 1
Hard tabs

(MD010, no-hard-tabs)


Line range hint 1-340: LGTM: README.md updated successfully.

The changes to the README.md file have been reviewed and are approved. The updates primarily focus on the contributors section, adding new contributors and updating existing entries. These changes:

  1. Maintain the existing structure and formatting of the document.
  2. Properly recognize and credit project contributors.
  3. Do not introduce any issues or inconsistencies in the documentation.

The pull request can be merged as is.

🧰 Tools
🪛 Markdownlint

208-208: Column: 1
Hard tabs

(MD010, no-hard-tabs)


209-209: Column: 1
Hard tabs

(MD010, no-hard-tabs)

Comment on lines +8 to +18
// useEffect to add/remove class to body for disabling scroll when modal is visible
useEffect(() => {
if (isVisible) {
document.body.style.overflow = 'hidden';
} else {
document.body.style.overflow = 'auto';
}
return () => {
document.body.style.overflow = 'auto';
};
}, [isVisible]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider using CSS classes for managing body overflow.

While the current implementation works, directly manipulating the DOM can sometimes lead to unexpected behavior, especially in more complex applications. Consider using CSS classes to manage the body overflow instead.

Here's an alternative approach using CSS classes:

  1. Add a class to your global CSS file:
.modal-open {
  overflow: hidden;
}
  1. Modify the useEffect hook as follows:
 useEffect(() => {
   if (isVisible) {
-    document.body.style.overflow = 'hidden';
+    document.body.classList.add('modal-open');
   } else {
-    document.body.style.overflow = 'auto';
+    document.body.classList.remove('modal-open');
   }
   return () => {
-    document.body.style.overflow = 'auto';
+    document.body.classList.remove('modal-open');
   };
 }, [isVisible]);

This approach is more declarative and easier to maintain, especially if you need to add more styles to the body when the modal is open.

@RamakrushnaBiswal
Copy link
Owner

@dev129 increase the size
image

@dev129
Copy link
Author

dev129 commented Oct 12, 2024

Very well, but you tell me all the changes at once, it becomes easier for me to maintain. Are you are that is the only change ?

@RamakrushnaBiswal
Copy link
Owner

@dev129 you need to just commit with your branch
no need to create a new PR

Copy link
Contributor

This PR has been automatically closed due to inactivity from the owner for 3 days.

@github-actions github-actions bot added the Stale label Oct 16, 2024
@github-actions github-actions bot closed this Oct 16, 2024
@dev129 dev129 deleted the feat-IncentiveOffers branch October 16, 2024 08:52
@dev129 dev129 restored the feat-IncentiveOffers branch October 17, 2024 03:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants